using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.TeamFoundation.Build.Client;

namespace Bazookabird.Common
{
    public class BuildDefinitionWrapper
    {
        private readonly IBuildDefinition _buildDefinition;

        public BuildDefinitionWrapper(IBuildDefinition buildDefinition)
        {
            _buildDefinition = buildDefinition;
        }

        public void Refresh()
        {
            _buildDefinition.Refresh();
        }

        public Uri Uri
        {
            get { return _buildDefinition.Uri; }
        }

        public string Name
        {
            get { return _buildDefinition.Name; }
            set { _buildDefinition.Name = value; }
        }

        public string TeamProject
        {
            get { return _buildDefinition.TeamProject; }
        }

        public string FullPath
        {
            get { return _buildDefinition.FullPath; }
        }

        public BuildDetailWrapper[] QueryBuilds()
        {
            var iBuildDetailArray = _buildDefinition.QueryBuilds();
            return iBuildDetailArray.Select(item => new BuildDetailWrapper(item)).ToArray();
        }

        public IBuildController BuildController
        {
            get { return _buildDefinition.BuildController; }
            set { _buildDefinition.BuildController = value; }
        }

        public Uri BuildControllerUri
        {
            get { return _buildDefinition.BuildControllerUri; }
        }

        public string Description
        {
            get { return _buildDefinition.Description; }
            set { _buildDefinition.Description = value; }
        }

        public string DefaultDropLocation
        {
            get { return _buildDefinition.DefaultDropLocation; }
            set { _buildDefinition.DefaultDropLocation = value; }
        }

        public bool Enabled
        {
            get { return _buildDefinition.Enabled; }
            set { _buildDefinition.Enabled = value; }
        }

        public string Id
        {
            get { return _buildDefinition.Id; }
        }

        public List<IRetentionPolicy> RetentionPolicyList
        {
            get { return _buildDefinition.RetentionPolicyList; }
        }

        public List<ISchedule> Schedules
        {
            get { return _buildDefinition.Schedules; }
        }

        public IWorkspaceTemplate Workspace
        {
            get { return _buildDefinition.Workspace; }
        }

        public Uri LastBuildUri
        {
            get { return _buildDefinition.LastBuildUri; }
        }

        public Uri LastGoodBuildUri
        {
            get { return _buildDefinition.LastGoodBuildUri; }
        }

        public string LastGoodBuildLabel
        {
            get { return _buildDefinition.LastGoodBuildLabel; }
        }

        public IProcessTemplate Process
        {
            get { return _buildDefinition.Process; }
            set { _buildDefinition.Process = value; }
        }

        public string ProcessParameters
        {
            get { return _buildDefinition.ProcessParameters; }
            set { _buildDefinition.ProcessParameters = value; }
        }

        public ContinuousIntegrationType ContinuousIntegrationType
        {
            get { return _buildDefinition.ContinuousIntegrationType; }
            set { _buildDefinition.ContinuousIntegrationType = value; }
        }

        public int ContinuousIntegrationQuietPeriod
        {
            get { return _buildDefinition.ContinuousIntegrationQuietPeriod; }
            set { _buildDefinition.ContinuousIntegrationQuietPeriod = value; }
        }

        public IBuildServer BuildServer
        {
            get { return _buildDefinition.BuildServer; }
        }
    }
}